<template>
  <div class="search">
    <el-input placeholder="请输入内容" v-model="value">
      <template slot="append">
        <el-button icon="el-icon-search" @click="handerValue"></el-button>
      </template>
    </el-input>
    <slot name="btn">
      <!-- 按钮插槽 可直接复制使用 -->
      <!-- <el-button type="primary" slot="btn">添加商品</el-button> -->
    </slot>
  </div>
</template>

<script>
export default {
  name: "SearchView",
  data() {
    return {
      value: "",
    };
  },

  mounted() {},

  methods: {
    //将当前搜索框输入的value值上传到父组件
    handerValue() {
      this.$emit("getValue", this.value);
      this.value = "";
    },
  },
};
</script>

<style lang="scss" scoped>
.search {
  width: 100%;
  display: flex;
  align-items: center;
  .el-input {
    margin-right: 20px;
  }
}
</style>